$(function(){
})
var httpipstr="http://118.178.18.0:8082/";
//var httpipstr="http://120.27.192.10/";
var loginGetSingleOpenIdtype;
function GetSingleOpenId(openid){
	var json = {"openid": ""+openid+""}
	$.ajax({
		cache: false,
		type: "post",
		dataType:"json",/*加上datatype*/
		data: JSON.stringify(json),
		contentType: 'application/json;charset=UTF-8',
		url: ''+httpipstr+'alfa-mobile-ws/rest/OpenId/GetSingleOpenId',
		success: function(data) {
			if(data.message=="1"){
				$("#heard").css('background','url('+data.data.headimgurl+') no-repeat'); 
				$("#heard").css('background-size','110% 110%'); 
				setcookie("roleId", "", 30, "/");
				if(data.data.mobiletoken==""||data.data.mobiletoken==null){
					clearsalesmanCookieWithIdAll()
					clearuserCookieWithIdAll()
				}else{
					if(data.data.roleId=="10"){
						clearsalesmanCookieWithIdAll()
						setcookie("roleId", data.data.roleId, 30, "/");
						setcookie("mobiletokenuser", data.data.mobiletoken, 30, "/");
						setcookie("username", data.data.mobile, 300, "/");
						setcookie("useriphone", data.data.mobile, 300, "/");
						setcookie("realname", data.data.realname, 300, "/");
						setcookie("orgname", data.data.orgname, 300, "/");
						setcookie("userid", data.data.sysuserid, 300, "/");
						setcookie("address", data.data.address, 300, "/");
					}else if(data.data.roleId=="9"){
						clearuserCookieWithIdAll()
						setcookie("salesmanid", data.data.sysuserid, 300, "/");
						setcookie("mobiletokensalesman", data.data.mobiletoken, 300, "/");
						setcookie("username", data.data.username, 300, "/");
						setcookie("salesmaniphone", data.data.mobile, 300, "/");
						setcookie("roleId", data.data.roleId, 30, "/")
					}
				}
				
			}else{
				var requestpath=$("#requestpath").val();
				$.ajax({
					cache: false,
					type: "post",
					dataType:"json",/*加上datatype*/
					data: JSON.stringify(json),
					contentType: 'application/json;charset=UTF-8',
					url: 'http://tugo.cn/weixin_aef/recycle/addopenidinfo',
					success: function(data) {
						if(data.code=="0"){
						}
					}
				})
			}
			
		}
	});
}

function httpget(url){
	var json
	$.ajax({
		type: "get",
		url: url,
		dataType: "json",
		async :false,
		success: function(data) {
			json= data
		}
			
		});
	return json
}
function httppost(url,json){
	var returndata
	$.ajax({
		cache: false,
		type: "post",
		datatype: 'json',
		contentType: 'application/json;charset=UTF-8',
		url: url,
		data: JSON.stringify(json),
		success: function(data) {
			returndata= data
		}
	});
	return returndata
}
function judgeloginstate(){
	var returndata="";
	var json = {
			"userId": "1"
		}
	$.ajax({
		cache: false,
		type : "post",
		datatype : 'json',
		contentType : 'application/json;charset=UTF-8',
		data: JSON.stringify(json),
		url : ''+httpipstr+'alfa-mobile-ws/rest/user/GetCurrentUserInfoForWeiXin?mobiletoken='+getCookie("mobiletokenuser")+'',
		success : function(data) {
			returndata=true;
		}, 
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			returndata=false;
			}
	});
	return returndata
}
